/*
 * @lc app=leetcode.cn id=27 lang=java
 *
 * [27] 移除元素
 */

// @lc code=start
class Solution {

  public int removeElement(int[] nums, int val) {
    int n = nums.length;
    int index = 0;
    for (int i = 0; i < n; i++) {
      if (nums[i] != val) {
        nums[index++] = nums[i];
      }
    }
    return index;
  }
}
// @lc code=end
